import request from '@/utils/request'

// 查询通知公告列表
export function listAnnouncement(query) {
  return request({
    url: '/system/announcement/list',
    method: 'get',
    params: query
  })
}

// 查询通知公告详细
export function getAnnouncement(announcementId) {
  return request({
    url: '/system/announcement/' + announcementId,
    method: 'get'
  })
}

// 新增通知公告
export function addAnnouncement(data) {
  return request({
    url: '/system/announcement',
    method: 'post',
    data: data
  })
}

// 修改通知公告
export function updateAnnouncement(data) {
  return request({
    url: '/system/announcement',
    method: 'put',
    data: data
  })
}

// 删除通知公告
export function delAnnouncement(announcementId) {
  return request({
    url: '/system/announcement/' + announcementId,
    method: 'delete'
  })
}

// 导出通知公告
export function exportAnnouncement(query) {
  return request({
    url: '/system/announcement/export',
    method: 'get',
    params: query
  })
}

// 查询下拉树结构
export function treeselect() {
  return request({
    url: '/system/statute/treeselect',
    method: 'get'
  })
}

// 置顶修改
export function changeTop(announcementId, istop) {
  const data = {
    announcementId,
    istop
  }
  return request({
    url: '/system/announcement/changeTop',
    method: 'put',
    data: data
  })
}

//下载文件
export function getFile (url){
  return request({
    url: url,
    method: 'get',
    responseType: 'arraybuffer'
  })
}
